package com.liang.seven_Topic_Exchanges;

import com.rabbitmq.client.Channel;
import utils.RabbitmqUtil;

import java.io.IOException;
import java.util.Scanner;
import java.util.concurrent.TimeoutException;

/**
 * Created with IntelliJ IDEA.
 * User: XIAOLIANG
 * Date: 2021/6/18
 * Time: 20:42
 * Description:  主题模式 生产者
 *
 *
 */
public class EmitLog_Topic {

    public static final String EXCHANGES_NAME = "topic_logs";

    public static void main(String[] args) throws IOException, TimeoutException {

        Channel channel = RabbitmqUtil.getChannel();

        channel.exchangeDeclare(EXCHANGES_NAME,"topic");

        Scanner scanner = new Scanner(System.in);



        while (true){

            System.out.println("输入消息");
            String message = scanner.nextLine();

            System.out.println("输入routingKey");
            String routingKey = scanner.nextLine();


            if (message.equals("exit")){
                break;
            }

            channel.basicPublish(EXCHANGES_NAME,routingKey,null,message.getBytes("UTF-8"));


        }







    }

}